<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <ul>
            <li><router-link to="/">Home</router-link></li>
            <li><router-link to="/user">User</router-link></li>
            <li><router-link to="/profile">Profile</router-link></li>
        </ul>
        <router-view></router-view>
    </div>
    <script src="https://unpkg.com/vue@2/dist/vue.js"></script>
    <!-- <script src="https://unpkg.com/vue-router@3/dist/vue-router.js"></script>  -->
    <script src="vue-router.js"></script> 
    <script>
        Vue.use(VueRouter);//只有使用了这句话后，才会安装插件
        const Home = {template:'<div>Home</div>'}
        const User = {template:'<div>User</div>'}
        const Profile = {template:'<div>Profile</div>'}
        //路由配置，就是什么路径对应什么组件
        var routes = [
            {path:'/',component:Home},
            {path:'/user',component:User},
            {path:'/profile',component:Profile}
        ]
        var router = new VueRouter({routes});
        var vm = new Vue({//vm.$router=VueRouter实例
            el:'#app',
            router
        });
        console.dir(vm)
    </script>
</body>
</html>